home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / glibc108.gz / glibc108 / glibc-1.08.1 / sysdeps / alpha / divrem.m4 < prev    next >
Text File  |  1993-12-23  |  848b  |  49 lines

  1. /* For each N divided by D, we do:
  2.       result = (double) N / (double) D
  3.    Then, for each N mod D, we do:
  4.       result = N - (D * divMODE (N, D))
  5.  
  6.    FIXME:
  7.    The q and qu versions won't deal with operands > 50 bits.  We also
  8.    don't check for divide by zero.  */
  9.  
  10. #include "DEFS.h"
  11. #if 0
  12. /* We do not handle div by zero yet.  */
  13. #include <machine/pal.h>
  14. #endif
  15. #include <regdef.h>
  16.  
  17. define(path, `SYSDEP_DIR/macros.m4')dnl
  18. include(path)
  19.  
  20. FUNC__(OP)
  21.     ! First set up the dividend.
  22.     EXTEND(t10)
  23.     stq t10,0(sp)
  24.     ldt $f10,0(sp)
  25.     cvtqt $f10,$f10
  26.     ADJQU($f10)
  27.  
  28.     ! Then set up the divisor.
  29.     EXTEND(t11)
  30.     stq t11,0(sp)
  31.     ldt $f1,0(sp)
  32.     cvtqt $f1,$f1
  33.     ADJQU($f1)
  34.  
  35.     ! Do the division.
  36.     divt $f10,$f1,$f10
  37.     cvttqc $f10,$f10
  38.  
  39.     ! Put the result in t12.
  40.     stt $f10,0(sp)
  41.     ldq t12,0(sp)
  42.     FULLEXTEND(t12)
  43.  
  44.     DOREM
  45.  
  46.     lda sp,16(sp)
  47.     ret zero,(t9),1
  48.     .end NAME__(OP)
  49.